package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anno.AutoFill;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {
    /**
     * 分类管理的分页查询
     * @param categoryPageQueryDTO
     * @return
     */
    Page<Category> list(CategoryPageQueryDTO categoryPageQueryDTO);

    /**
     * 新增分类
     * @param category
     */
    @AutoFill(OperationType.INSERT)
    @Insert("INSERT INTO category values (null,#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void addCategory(Category category);

    /**
     * 启用，禁用分类
     * @param category
     */
    @Update("update category set status=#{status} where id=#{id}")
    void update(Category category);


    /**
     * 根据id删除分类
     * @param id
     */

    @Delete("delete  from  category where id=#{id}")
    void delete(Long id);

    /**
     * 根据类型查询
     * @param type
     * @return
     */
   // @Select("SELECT *FROM category where type=#{type}")
List<Category> select(Integer type);

    /**
     * 修改分类
     * @param category
     */
    @AutoFill(OperationType.UPDATE)
    void updateCategory(Category category);

}
